import React, { useEffect, useState } from 'react'
// import { useParams } from 'react-router-dom'
import { useSearchParams } from 'react-router-dom'
import api from '@/api'
import '../../assets/style/categoryproduct.scss'

export default function CategoryProduct() {
  const [products,setProducts]=useState([])
//   const params=useParams()
const [params]=useSearchParams()
  useEffect(()=>{
    getCategoryChild(params.get('idx'))
  },[params])
  const getCategoryChild=async index=>{
    const result=await api.category.getCategory()
    if(result.data.data[index].child){
        setProducts(result.data.data[index].child)
    }
  }
  return (
    <div className='product-container'>
       {
        products.map((item,index)=><div className='item' key={index}>
            <div className="item-header">
                <img src={item.extra} alt="" />
            </div>
        </div>)
       }
    </div>
  )
}
